import { ArticleService } from '@/service/ArticleService'
import { ArticleDao } from '@/dao/ArticleDao'
import { Service, Inject } from 'typedi';
import { res } from '@/utils/jsonResult';
import { Article, categories } from '@/m_res/Article'
import { CommentParams } from '@/model/request/Comment';
import { Token } from '@/m_req/Token'

@Service()
export class ArticleServiceImpl implements ArticleService {
   

    @Inject()
    articleDao!: ArticleDao

    async pushComment(params: CommentParams, token: Token): Promise<res<string>> {
        return await this.articleDao.pushCommentDao(params, token);
    }

    async GetArticleList(): Promise<res<Array<Article>>> {
        return await this.articleDao.GetArticleDao();
    }

    async GetArticleInfo(id: number): Promise<res<null>> {
        return await this.articleDao.GetArticleInfoDao(id);
    }

    async GetCategoriesList(): Promise<res<categories[]>>{
        return await this.articleDao.GetCategoriesListDao();
    }

    async GetCategoriesInfo(id: number): Promise<res<Article[]>>{
        return await this.articleDao.GetCategoriesInfoDao(id);
    }

    async GetSearch(word: string): Promise<res<Article[]>> {
        return await this.articleDao.SearchDao(word);
    }
}